package com.yanqu.road.server.cmd.orewar;

import com.yanqu.road.entity.crossorewar.CrossUserOrePit;
import com.yanqu.road.pb.orewar.OreWarProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.orewar.CrossOreWarMgr;
import com.yanqu.road.server.pb.orewar.CrossOreWarPb;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;



@Cmd(code = Protocol.C_CROSS_ORE_WAR_DETECT_USER, desc = "侦查坑位门客")
public class CrossOreWarDetectUserPitCmd extends CrossUnionCommand {

    private int activityId;

    private long userId;

    private int pitId;

    private long reqUserId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        OreWarProto.CrossOreDetectUserOrePitReqMsg reqMsg = OreWarProto.CrossOreDetectUserOrePitReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        userId = reqMsg.getUserId();
        pitId = reqMsg.getPitId();
        reqUserId = packet.getPlayerId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossUserOrePit crossUserOrePit = CrossOreWarMgr.getCrossUserOrePit(activityId, pitId,groupId);

        OreWarProto.CrossOreDetectUserOrePitRespMsg.Builder respMsg = OreWarProto.CrossOreDetectUserOrePitRespMsg.newBuilder();
        respMsg.setUserId(userId);
        respMsg.setRet(0);
        OreWarProto.CrossOrePitTempMsg.Builder tempMsg = CrossOreWarPb.parseCrossOrePitTempMsg(crossUserOrePit);
        respMsg.setOrePit(tempMsg);
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(Protocol.S_CROSS_ORE_WAR_DETECT_USER, respMsg);
        MessageHelper.sendPacket(serverId, reqUserId, pbMsg);
    }

    @Override
    public void sendData() {

    }
}
